var config = require(process.cwd() + '/rightfe')
if (!config.html) return

var browserSync = require('browser-sync')
var gulp = require('gulp')
var gulpif = require('gulp-if')
var handleErrors = require('../utils/handleErrors')
var htmlmin = require('gulp-htmlmin')
  //替换处理 
var processhtml = require('gulp-processhtml')
var path = require('path')
var fs = require('fs')

var paths = {
  src: path.join(config.root.src, config.html.src, '/**/*.{' + config
    .html.extensions + '}'),
  dest: path.join(config.root.dest, config.html.dest),
};

var htmlTask = function(publish) {
  return gulp.src(paths.src)
    .pipe(gulpif(publish, htmlmin(config.html.htmlmin)))
    .pipe(processhtml())
    .pipe(gulp.dest('./' + paths.dest))
    .pipe(browserSync.stream())
}

module.exports = htmlTask
